package com.up360.rapidcalc.global
{
	import flash.events.ContextMenuEvent;
	import flash.ui.ContextMenu;
	import flash.ui.ContextMenuItem;
	
	/**
	 * Author:郎福涛
	 * Date: Dec 6, 2012 11:57:25 AM
	 * Synopsis:
	 */
	public class GlobalContextMenu
	{
		private static var _instance:GlobalContextMenu;
		
		private var _contextMenu:ContextMenu;
		/**
		 * 全局的（文档类的)的右键菜单，本类为单例，不要实例化此类，使用此类请使用instance
		 */		
		public function GlobalContextMenu()
		{
			_contextMenu=new ContextMenu();
			LayerManager.mainLayer.contextMenu=_contextMenu;
		}
		public function get contextMenu():ContextMenu{
			return _contextMenu;
		}
		/**
		 * 初始化全局的右键菜单
		 */		
		public static function initialize():void{
			instance;
		}
		private function addMenuItem(caption:String,menuItemSelectFun:Function):void{
			var b_contextMenuItem:ContextMenuItem=new ContextMenuItem(caption,false,true,true);
			b_contextMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,menuItemSelectFun);
			_contextMenu.customItems.push(b_contextMenuItem);
		}
		public static function get instance():GlobalContextMenu{
			if(!_instance) _instance=new GlobalContextMenu();
			return _instance;
		}
	}
}